﻿using System;
using System.Activities;
using System.Collections.Generic;

namespace Vision.Core.ActivityComponents.Collections
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TKey"></typeparam>
    /// <typeparam name="TValue"></typeparam>
    public class ExistsInDictionary<TKey, TValue> : CodeActivity<Boolean>
    {
        [RequiredArgument]
        public InArgument<IDictionary<TKey, TValue>> Dictionary { get; set; }
        [RequiredArgument]
        public InArgument<TKey> Key { get; set; }

        protected override Boolean Execute(CodeActivityContext context)
        {
            Boolean result = false;
            IDictionary<TKey, TValue> dictionary = Dictionary.Get(context);
            TKey key = Key.Get(context);
            if (dictionary != null)
            {
                result = dictionary.ContainsKey(key);
            }
            return result;
        }
    }
}
